<div id="main_home">
<div id="categories_home" class="content">
	<ul>
		<li id="sports"><?PHP echo $html->link('Sport', "/categories/view/sport"); ?></li>
		<li id="politics"><?PHP echo $html->link('Politics', "/categories/view/politics"); ?></li>
		<li id="celebrities"><?PHP echo $html->link('Celebrities', "/categories/view/celebrities"); ?></li>
		<li id="business"><?PHP echo $html->link('Business', "/categories/view/business"); ?></li>
		<li id="other"><?PHP echo $html->link('Other', "/categories/view/other"); ?></li>
	</ul>	
</div>
<div class="content">
<h1>Items</h1>


<table>
	<tr>
		<th>Item Id</th>
		<th>Name</th>
        <th>Resign!</th>
        <th>Number of plz RESIGN!</th>
	</tr>
    
    Number of items in database: <?php echo $no_items; ?>

<!-- Here's where we loop through our $posts array, printing out post info -->

	<?php foreach ($items as $item): ?>
	<tr>
		<td><?php echo $item['Item']['id']; ?></td>
		<td><?php echo $html->link($item['Item']['name'], "/items/view/".$item['Item']['id']); ?></td>
        <td><?php echo $html->link('Resign!!', array('controller'=>'votes','action'=>'add', $item['Item']['id'])); ?></td>
        
        
        <!-- Print out how many votes for item, Tis can be done better in controller -->
        <?php 
		$no = 0;
		foreach ($item['Vote'] as $vote): 
		$no++;
		endforeach; 
		?>
        <td><?php echo $no; ?></td>
	</tr>
	<?php endforeach; ?>

</table>
</div>
</div>